package com.woniuxy.controller;


import com.woniuxy.entity.Withdrawal;
import com.woniuxy.entity.dto.WithdrawalDTO;
import com.woniuxy.service.WithdrawalService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/withdrawal")
public class WithdrawalController {

    @Resource
    private WithdrawalService withdrawalService;


    @PostMapping("/queryWithdrawal")
    public ResponseData<?> queryWithdrawal(@RequestBody PageParam<Withdrawal> pageParam){
        Assert.notNull(pageParam,"pageParam is not null");
        return withdrawalService.queryList(pageParam);
    }

    //添加退药申请表 以及退药明细表
    @PostMapping("addWithdrawal")
    public ResponseData<?> addWithdrawal(@RequestBody WithdrawalDTO withdrawalDTO){
        return withdrawalService.addWithdrawal(withdrawalDTO);
    }


    //查询药品详情
    @GetMapping("/queryDrug/{dwNo}")
    public ResponseData<?> queryDrug(@PathVariable("dwNo")String dwNo){
        return withdrawalService.queryDrugReturnDetail(dwNo);
    }

    //同意
    @GetMapping("/updateWithdrawal/{id}")
    public ResponseData<?> updateWithdrawal(@PathVariable("id")Integer id){
        Assert.notNull(id,"id is not null");
        return withdrawalService.updateWithdrawal(id);
    }
}
